package com.mo2323.merchant.secruity;

import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 覆盖Spring.Security包中的NoOpPasswordEncoder类
 * Spring.Security包中的同名类做已过期处理，但目前项目中确实不需要对密码进行加密认证
 *
 * @author 高岐
 * @date 2019-01-22.
 */
public class NoOpPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        return rawPassword.toString();
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return rawPassword.toString().equals(encodedPassword);
    }

    public static PasswordEncoder getInstance() {
        return INSTANCE;
    }

    private static final PasswordEncoder INSTANCE = new NoOpPasswordEncoder();

    private NoOpPasswordEncoder() {
    }
}
